package com.lsy.controller.back;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lsy.entity.InvestCustom;
import com.lsy.service.interf.InvestService;

@Controller
@RequestMapping("/back/invest")
public class InvestBackController {

	@Autowired
	private InvestService investService;

	@RequestMapping("/list")
	public String query(Model model) {

		try {
			List<InvestCustom> list = investService.findList();
			model.addAttribute("invests", list);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return "/BackEnd/investList";
	}

	@RequestMapping("/queryById")
	@ResponseBody
	public InvestCustom query(int id) {
		InvestCustom invest = null;
		try {
			invest = investService.findInvest(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return invest;
	}

}
